<extend name="Public/base"/>

<block name="body">
	<div class="main-title">
		<h2>{$main_title}</h2>
	</div>

	<div class="cf">
		<a class="btn" href="{:U('add')}">新 增</a>
		<a class="btn ajax-post" url="{:U('remove')}" target-form="ids">删 除</a>
		
		<!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="请输入联系人姓名">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U()}"><i class="btn-search"></i></a>
			</div>
		</div>
	</div>

	<div class="data-table table-striped">
		<table>
			<thead>
				<tr>
					<th class="row-selected">
						<input class="checkbox check-all" type="checkbox">
					</th>
					<th>ID</th>
					<th>姓名</th>
					<th>性别</th>
					<th>手机</th>
					<th>住址</th>
					<th>籍贯</th>
					<th>部门</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<volist name="list" id="config">
					<tr>
						<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$config.uid}"></td>
						<td>{$config.uid}</td>
						<td><a href="{:U('edit?id='.$config['uid'])}">{$config.nickname}</a></td>
						<td>{$config.sex|sex}</td>
						<td>{$config.mobile}</td>
						<td>{$config.address}</td>
						<td>{$config.hometown}</td>
						<td>{$config.department}</td>
						<td>
							<a title="编辑" href="{:U('edit?id='.$config['uid'])}">编辑</a>
							<a class="confirm ajax-get" title="删除" href="{:U('remove?id='.$config['uid'])}">删除</a>
						</td>
					</tr>
				</volist>
			</tbody>
		</table>
		<!-- 分页 -->
	    <div class="page">
	        {$_page}
	    </div>
	</div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
});
</script>
</block>